package com.xxx.request;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RequestDome01 extends HttpServlet {
    @Override    //通过HttpServletRequest来获取数据
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        System.out.println("请求头："+req.getHeader("User-Agent"));//请求头信息
//        System.out.println("请求协议"+req.getScheme());//协议
//        System.out.println("服务器名："+req.getServerName());//服务器名
//        System.out.println("项目名："+req.getContextPath());//项目名
//        System.out.println("servlet路径："+req.getServletPath());//请求参数
//        System.out.println("   "+req.getRequestURI());//完整路径
//        System.out.println("   "+ req.getServerPort());//端口
        String name = req.getParameter("name");
        System.out.println("name = " + name);
        String age = req.getParameter("age");
        System.out.println("age = " + age);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
